/*
  S.M.A.C.K - An operating system kernel
  Copyright (C) 2010,2011 Mattias Holm and Kristian Rietveld
  For licensing and a full list of authors of the kernel, see the files
  COPYING and AUTHORS.
*/

/*!
  Hardware Abstraction Layer

  This file contains function prototypes that implement a simple HAL. All
  targets must implement these functions.
 */

#ifndef KERNEL__HAL_H
#define KERNEL__HAL_H

#include <stdint.h>
#include <arch-types.h>
#include <vm.h>

/*!
  Invalidates at least the TLB entries corresponding to va and size.
  To invalidate the entire TLB, pass 0 for both va and size.
 */
void hw_tlb_invalidate(va_t va, size_t size);
/*!
  Flushes the cache for the address and size. In order to flush the entire
  cache, pass 0 for va and size.
*/
void hw_cache_flush(va_t va, size_t size);

void hw_mmu_init(void);

/*!
  Maps a virtual address range to a physical address range. For targets without
  MMU, the function will apply the permission bits in the flags parameter, but
  no remapping. For targets without MPUs, the function should be empty.
*/
void hw_map(vm_map_t *vm, va_t va, pa_t pa, size_t size, uint32_t flags);
void hw_unmap(vm_map_t *vm, va_t addr, size_t sz);

/*!
  Translates a virtual address to a physical. This function is important for
  device drivers that need to hand over the physical address to device registers.
*/
pa_t hw_probe(vm_map_t *vm, va_t vaddr);

void __attribute__((naked)) hw_idle(void);

#endif /* !KERNEL__HAL_H */

